package com.lzj.demo.design.iterator.lcq;

public class ChineseFoodMenu implements Menu{
    private String[] foods = new String[4];
    private int position = 0;

    @Override
    public void add(String name) {
        foods[position] = name;
        position += 1;
    }

    @Override
    public void remove(int index) {
        while (index < foods.length-1){
            foods[index] = foods[index+1];
            index += 1;
        }
        foods[foods.length-1] = "";
    }

    @Override
    public Iterator getIterator() {
        return new MenuIterator(this.foods);
    }
}
